package com.zhanghe.study.springboot.controller;

import com.zhanghe.study.springboot.configuration.CustomConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zh
 * @date 2021/2/27 17:08
 */
@Controller
public class HelloWorldController {

    @Autowired
    private CustomConfig config;

    @ResponseBody
    @RequestMapping("/hello")
    public String hello(){
        return "Hello World"+config.getName();
    }


    @ResponseBody
    @RequestMapping("/body")
    public String body(@RequestBody TestJson testJson){
        return testJson.getName();

    }


    public static class TestJson{
        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
